<?php
/**
 * 
 * @author yuxun
 *
 */

class ModEveryGrade {

    public static function indexData($params){
        $where  = ' WHERE GameSrc=:game ';
        $args   = array(
            ':game'     => $params['g'],
        );
        
        $user = AccAuth::me();
        if($params['os'] != 'ALL' || $user['IsViewAll'] != 1){
        	$where .= " AND Platform=:p ";
        	$args[':p'] = $params['os'];
        }
        
        if($params['os'] == 'ALL' && $params['server'] == 'ALL'){  //都为all，查询专服下的所有渠道的服务器
        	$modServer = new ModServer();
        	$list = $modServer->getServerForSpecialId($params['g'],$params['special_id']);
        	$where .= " AND ( ";
        	foreach ($list as $key=>$val){
        		$where .= " SID = '{$val['develop_id']}'  or";
        	}
        	$where = substr($where, 0, -2);
        	$where .= " ) ";
        }else{
        	$where .= " AND SID=:ser ";
        	$args[':ser'] = empty($params['server']) ? 'ALL' : $params['server'];
        }

        $table = 'tblgameeverygrade';

        $sql = "SELECT * FROM {$table} {$where}";

        $dbLink = new PubDbLink('dbSelf', PubDatabase::getMgmtDbName($params['p'], $params['g']));
        return $dbLink->query($sql, $args);
    }

} 
